package com.wwmz.mebatis.v2;

import com.wwmz.mebatis.v2.mapper.Blog;
import com.wwmz.mebatis.v2.mapper.BlogMapper;
import com.wwmz.mebatis.v2.session.DefaultSqlSession;
import com.wwmz.mebatis.v2.session.SqlSessionFactory;

/**
 * Created by wumz on 2020/10/17 9:59
 */
public class TestMyBatis {

    public static void main(String[] args) {
        //创建会话工厂类 SqlSessionFactory
        SqlSessionFactory sessionFactory = new SqlSessionFactory();

        //创建一次会话 SqlSession的默认实现类 DefaultSqlSession
        DefaultSqlSession sqlSession = sessionFactory.build().openSqlSession();

        //通过代理拿到Mapper的代理对象
        BlogMapper mapper = sqlSession.getMapper(BlogMapper.class);

        //执行SQL语句
        Blog blog = mapper.selectBlogById(1);

        System.out.println(blog);
    }
}
